<template>
	<view class="index-product-wrapper" :class="iSshowH?'on':''" :style="'margin-top:'+mbConfig*2+'rpx;'"
		v-show="!isSortType">
		<view class="nav-bd"
			:style="{justifyContent:titleConfig===0?'flex-start':titleConfig===1?'space-around':'flex-end'}">
			<image class="hot_img" :src="hot_img" mode="aspectFit"></image>
			<view class="item" v-for="(item,index) in explosiveMoney" :index="index"
				@click="ProductNavTab(item.link.activeVal,index)">
				<view class="txt" :style="{ 'color': index==ProductNavindex ? themeColor : '' }">
					{{$t(item.chiild[0].val)}}
				</view>
				<!-- 				<view class="label"
					:style="{ 'background': index==ProductNavindex ? themeColor : '','color': index==ProductNavindex ? '#fff' : '' }">
					{{$t(item.chiild[1].val)}}</view> -->
			</view>
		</view>
		<!-- 首发新品 -->
		<scroll-view scroll-x="true" class="list-box animated" :class='tempArr.length > 0?"fadeIn on":""'>
			<view class="item" v-for="(item,index) in tempArr" :key="index" @click="goDetail(item)">
				<view class="pictrue">
					<span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor"
						v-if="item.activity && item.activity.type === '1'">{{$t(`秒杀`)}}</span>
					<span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor"
						v-if="item.activity && item.activity.type === '2'">{{$t(`砍价`)}}</span>
					<span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor"
						v-if="item.activity && item.activity.type === '3'">{{$t(`拼团`)}}</span>
					<!-- <image :src="item.image" mode="aspectFit"></image> -->
					<easy-loadimage mode="widthFix" :image-src="item.image"></easy-loadimage>
				</view>
				<view class="text-info">
					<view class="title line2" v-if="titleShow">{{item.store_name}}</view>
					<view class="old-price" v-if="opriceShow">{{$t(`￥`)}}{{item.ot_price}}</view>
					<view class="price" :style="{color:fontColor}">
						<view v-if="priceShow">
							<text>{{$t(`￥`)}}</text>{{item.price}}
						</view>
						<view class="txt" :style="'border:1px solid '+labelColor+';color:'+labelColor"
							:class="priceShow?'':'on'" v-if="item.checkCoupon && couponShow">{{$t(`券`)}}</view>
					</view>
				</view>
			</view>
		</scroll-view>
		<view class="todayHot">
			<view class="title">今日爆款</view>
			<image class="hot_img" mode="aspectFit" src="https://youzhenimg.sdshengyue.cn/attach/2024/01/6253c20240124161637596.png"></image>
		</view>
		<view class="uni-margin-wrap">
			<swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
				:duration="duration" >
				<swiper-item style="background-color: #fff;width: 90%;" v-for="(item,index) in tempArr" :key="index" @click="goDetail(item)">
					<image mode="aspectFill" class="sw_img" :src="item.image"></image>
					<view class="hot_today">
						<view class="name">{{item.store_name}}</view>
						<view class="price">{{$t(`￥`)}}{{item.ot_price}}</view>
						<view class="hot_btn">
							立即购买
							<view class="hot_son"></view></view>
					</view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'promotionList',
		props: {

			dataConfig: {
				type: Object,
				default: () => {}
			},
			tempArr: {
				type: Array,
				default: []
			},
			iSshowH: {
				type: Boolean,
				default: false
			},
			isSortType: {
				type: String | Number,
				default: 0
			}
		},
		data() {
			return {
				background: ['color1', 'color2', 'color3'],
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 1000,
				hot_img: 'https://youzhenimg.sdshengyue.cn/attach/2024/01/5796f202401241616374031.png',
				ProductNavindex: 0,
				explosiveMoney: this.dataConfig.tabConfig.list,
				numConfig: this.dataConfig.numConfig.val,
				// imgStyle: this.dataConfig.imgStyle.type,
				mbConfig: this.dataConfig.mbConfig.val,
				themeColor: this.dataConfig.themeColor.color[0].item,
				titleShow: this.dataConfig.titleShow.val, //标题是否显示
				opriceShow: this.dataConfig.opriceShow.val, //原价是否显示
				priceShow: this.dataConfig.priceShow.val, //价格是否显示
				couponShow: this.dataConfig.couponShow.val, //优惠券标签是否显示
				titleConfig: this.dataConfig.titleConfig.type, //标题位置
				fontColor: this.dataConfig.fontColor.color[0].item,
				labelColor: this.dataConfig.labelColor.color[0].item
			};
		},
		created() {},
		methods: {
			// 首发新品切换
			ProductNavTab(type, index) {
				this.ProductNavindex = index;
				this.$emit('changeTab', type);
			},
			goDetail(item) {
				this.$emit('detail', item);
			}
		}
	}
</script>

<style lang="scss">
	.hot_today{
		width: 100%;
		text-align: center;
		.name{
			width: 80%;
			// margin-left: 10%;
			font-size: 30rpx;
			margin: 10rpx 10%;
		}
		.price{
			color: red;
			font-size: 32rpx;
			margin-bottom: 10rpx;
		}
		.hot_btn{
			width: 220rpx;
			height: 64rpx;
			line-height: 64rpx;
			background: #212121;
			border-radius: 8rpx;
			margin: 0 auto;
			position: relative;
			color: #fff;
			.hot_son{
				width: 21rpx;
				height: 64rpx;
				background: #C6A46E;
				border-radius: 50% 8rpx 8rpx 50%;
				position: absolute;
				top: 0;
				right: 0;
			}
			
		}
	}
	.sw_img{
		width: 90%;	
		margin-left: 5%;
		height: 380rpx;
	}
	.todayHot{
		width: 100%;
		margin-top: 20rpx;
		position: relative;
		.title{
			width: 100%;
			border-radius: 20rpx 20rpx 0 0;
			background-color: #D1B173;
			color: #fff;
			height: 80rpx;
			line-height: 80rpx;
			padding-left: 20rpx;
			font-size: 32rpx;
		}
	}
	.uni-bg-red {
		background-color: red;
	}

	.uni-margin-wrap {
		width: 690rpx;
		width: 100%;
		// height: 700rpx;
		background-color: #DBC291;
	}

	.swiper {
		height: 650rpx;
		padding: 30rpx;
	}

	.swiper-item {
		display: block;
		height: 300rpx;
		line-height: 300rpx;
		text-align: center;
	}

	.swiper-list {
		margin-top: 40rpx;
		margin-bottom: 0;
	}

	.uni-common-mt {
		margin-top: 60rpx;
		position: relative;
	}

	.info {
		position: absolute;
		right: 20rpx;
	}

	.uni-padding-wrap {
		width: 550rpx;
		padding: 0 100rpx;
	}

	.hot_img {
		list-style: none;
		height: 40rpx;
		width: 300rpx;
		position: absolute;
		right: 20rpx;
		z-index: 999;
		bottom: 0;
	}

	.index-product-wrapper {
		margin: 30rpx 20rpx 0 20rpx;
		// background-color: #292E35;

		// border-radius: 20rpx;
		&.on {
			min-height: 1500rpx;
		}

		.nav-bd {
			display: flex;
			align-items: center;
			margin-top: 30rpx;
			background-color: #292E35;
			height: 80rpx;
			border-radius: 20rpx 20rpx 0 0;
			position: relative;

			.item {

				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				width: 25%;

				&.on {
					border-radius: 0;
				}

				.txt {
					font-size: 32rpx;
					color: #282828;
				}

				.label {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 124rpx;
					height: 32rpx;
					margin-top: 5rpx;
					font-size: 24rpx;
					color: #999;
					border-radius: 16rpx;
				}
			}
		}

		.list-box {
			width: calc(95% - 2px);
			padding: 20rpx;
			background-color: #2F373E;
			// border-radius: 20rpx;
			display: flex;
			overflow-x: hidden;
			// flex-wrap: wrap;
			// justify-content: space-between;
			// margin-top: 20rpx;
			white-space: nowrap;

			.item {
				border-radius: 10rpx;
				width: 246rpx;
				// margin-bottom: 20rpx;
				background-color: #fff;
				// border-radius: 20rpx;
				overflow: hidden;
				position: relative;
				display: inline-block;
				margin-right: 20rpx;

				/deep/.easy-loadimage image {
					width: 100%;
					height: 346rpx;
					border-radius: 20rpx 20rpx 0 0;
				}

				.pictrue_log {
					width: 92rpx;
					height: 44rpx;
					font-size: 26rpx;
					line-height: 44rpx;
				}

				image {
					width: 100%;
					height: 246rpx;
					display: block;
					border-radius: 20rpx 20rpx 0 0;
				}

				.text-info {
					padding: 10rpx 20rpx 15rpx;

					.title {
						color: #222222;
						line-height: 34rpx;
						height: 68rpx;
						font-size: 24rpx;
					}

					.old-price {
						margin-top: 4rpx;
						font-size: 22rpx;
						color: #AAAAAA;
						text-decoration: line-through;

						text {
							margin-right: 2px;
							font-size: 20rpx;
						}
					}

					.price {
						display: flex;
						align-items: flex-end;
						font-size: 30rpx;
						font-weight: 550;

						text {
							padding-bottom: 4rpx;
							font-size: 26rpx;
							font-weight: normal;
						}

						.txt {
							display: flex;
							align-items: center;
							justify-content: center;
							width: 28rpx;
							height: 28rpx;
							margin-left: 15rpx;
							margin-bottom: 10rpx;
							border-radius: 4rpx;
							font-size: 20rpx;
							font-weight: normal;

							&.on {
								margin-left: 0;
							}
						}
					}
				}
			}

			&.on {
				display: flex;
			}
		}
	}
</style>